package com.briup.day03;

/**
 * @author lining
 * @date 2024/1/10 14:21
 */
public class 交换数字 {
    public static void method(){
        int a = 1;
        int b = 2;
        int temp = 0;//中间变量
        temp = a;//防止被覆盖
        a = b;
        b = temp;
        System.out.println("a:\t"+a);
        System.out.println("b:\t"+b);
    }
    public static void main(String[] args) {
        int a = 1;
        int b = 2;
        a = a ^ b; // a = a^b
        b = a ^ b; // b = a^b^b  --> b = a
        a = a ^ b; // a =  a^b^a ---> a = b
        System.out.println("a:\t"+a);
        System.out.println("b:\t"+b);
//        System.out.println(10^5^5);
    }
}
